/* person.c */
#include "person.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Person Person_construct(int a, char * n) {
  Person p;
  p.age = a;
  p.name = malloc((strlen(n) + 1) * sizeof(char));
  strcpy(p.name, n);
  return p;
}
void Person_destruct(Person p) {
  free (p.name);
}
Person Person_copy(Person p) {
  return Person_construct(p.age, p.name);
}
void Person_assign(Person * p1, Person * p2) {
  /* replace = because it does shallow copy */
  if (p1 == p2) /* two objects are the same, do nothing */
    { return; } 
  Person_destruct (* p1);
  * p1 = Person_copy(* p2);
}
void Person_print(Person p) {
  printf("name: %s, age: %d\n", p.name, p.age);
}
int Person_getAge(Person p) {
  return p.age;
}
char * Person_getName(Person p) {
  return p.name;
}

